package com.wlyuan.open.scanner.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Optional;

/**
 * @author lijing
 * @description
 */
public class StrUtils extends StringUtils {

    /**
     * 关闭原因
     *
     * @param reason
     * @return
     */
    public static String closeReason(String reason) {
        return Optional.ofNullable(reason)
                .filter(x -> x.contains("关闭订单原因："))
                .map(x -> x.substring(x.indexOf("关闭订单原因：") + 8, x.length() - 1))
                .orElse(reason);
    }

    public static String refuseReason(String val) {
        return Optional.ofNullable(val)
                .filter(x -> x.contains("拒绝原因："))
                .map(x -> x.substring(x.indexOf("拒绝原因：") + 6, x.length() - 1))
                .orElse(val);
    }
}
